package com.bykj.property.mapper.provider;

import com.bykj.property.controller.vo.request.ChargeTypePageRequest;
import com.bykj.property.controller.vo.request.DoorCardPageRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author yiming
 * @title: DoorCardSql
 * @projectName property
 * @description: TODO
 * @date 2019/6/299:19
 */
public class DoorCardSql {
    public String getSql(DoorCardPageRequest pageRequest){
        return new SQL() {
            {
                SELECT("*");
                FROM("door_card");
                if(!StringUtils.isEmpty(pageRequest.getDoorCardNumber())) {
                    pageRequest.setDoorCardNumber("%"+pageRequest.getDoorCardNumber()+"%");
                    WHERE("door_card_number like #{doorCardNumber}");
                }
                if(pageRequest.getPmVillageId()!=null) {
                WHERE("pm_village_id = #{pmVillageId}");
            }
                if(pageRequest.getPmUnitId()!=null) {
                    WHERE("pm_unit_id like #{pmUnitId}");
                }

            }
        }.toString();

    }
}
